import math
import numpy

import common
import utils
import warningExtractor
import stormReportExtractor
import radarExtractor
import radarAnalysis
import vortTracker

def projectVortTrack(initPos, hdg, spd, t):
	""" returns the point at the end of the track beginning at initPos with heading hdg, speed spd, 
		and for time t. hdg in degrees, spd in mph, and t in minutes """
	
	lonChg = (math.sin(utils.degToRad(hdg))*(spd * (t/60.0)))/1.15/60.0
	latChg = (math.cos(utils.degToRad(hdg))*(spd * (t/60.0)))/1.15/60.0
	
	endPos = (initPos[0]+latChg, initPos[1]+lonChg)
	return endPos

def distFromVortTrack(point, projectedTrack):
	# must reverse the lat/lon pairs so they are x/y for the dist function
	lineStart = (projectedTrack[0][1], projectedTrack[0][0])
	lineEnd = (projectedTrack[1][1], projectedTrack[1][0])
	pt = (point[1], point[0])
	
	d = utils.ptLineDist(lineStart, lineEnd, pt)*60.0*1.15
	return d
	

def projectVortTrackTest():
	initPos = (36.00, -97.00)
	hdg = 90.0
	spd = 40.0
	t = 30.0
	endPos = projectVortTrack(initPos, hdg, spd, t)
	
	pt = (36.1, -96.85)
	d = distFromVortTrack(pt, (initPos, endPos))
	print d
